<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<!-- head 头部-->
<head th:replace="admin/layout/include::head('角色编辑','')"></head>
<body>
<form id="role-form" lay-filter="role-form" class="layui-form model-form">
    <input name="id" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label required">角色名</label>
        <div class="layui-input-block">
            <input name="roleName" placeholder="请输入角色名" type="text" class="layui-input" maxlength="20"
                  lay-verType="tips"  lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required" lay-tips="保存以后无法修改" lay-direction="2">
            角色编码 <span class="icon-text"><i class="layui-icon layui-icon-tips"></i></span>
        </label>
        <div class="layui-input-block">
            <input name="roleCode" id="roleCode" placeholder="请输入角色编码" type="text" class="layui-input" maxlength="20"
                  lay-verType="tips" lay-verify="required" required/>
        </div>
        <!-- <div class="layui-form-mid layui-word-aux">提交后无法修改</div> -->
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色类型</label>
        <div class="layui-input-block">
             <select name="roleType" lay-verify="required">
					<option value="1">管理角色</option>
					<option value="2">VIP角色</option>
			</select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
           <input name="orderNo" placeholder="排序" type="number" class="layui-input" lay-verify="number"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="description" placeholder="请输入内容" class="layui-textarea" maxlength="200"></textarea>
        </div>
    </div>
    <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        <button class="layui-btn" lay-filter="formSubmit" lay-submit>保存</button>
    </div>
</form>
<!-- js部分 -->
<div th:replace="admin/layout/include::js"></div>
<script>
    layui.use(['layer', 'admin', 'form', 'formSelects'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;

        // 回显数据
        var role = admin.getTempData('t_role');
        if (role) {
            form.val('role-form', role);
            //编码 禁止编辑
            $('#roleCode').attr("disabled","disabled");
        }

        // 表单提交事件
        form.on('submit(formSubmit)', function (data) {
            // 表单提交事件
            B.post({
                url: '/admin/role/',
                loading: true,
                data: data.field,
                success: function (data) {
                    if (data.success) {
                        top.layer.msg(data.msg, {icon: 1});
                        admin.putTempData('formOk', true);  // 操作成功刷新表格
                        // 关闭当前iframe弹出层
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    } else {
                        top.layer.msg(data.msg, {icon: 2});
                    }
                }
            });
            return false;
        });

    });
</script>

</body>